package com.example.springboot.config.componetAndConfiguration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * Configuration注解的能保证bean是单例的
 * Component保证下面的bean是多例的
 * @Author:ChenZhangKun
 * @Date: 2021/4/29 17:46
 */
//@Configuration
    @Component
public class ConfigurationAndComponentTest {
    @Bean
    public Driver driver() {
        Driver driver = new Driver();
        driver.setId("1");
        driver.setCar(car());
        return driver;
    }

    @Bean
    public Car car() {
        Car car = new Car();
        car.setColor("黑色");
        car.setId("2");
        return car;
    }
}

